﻿using System;
using System.Collections.Generic;


namespace DailyFx
{
	//public class MoneyManager 
	//{

	//	public struct Command // money transaction
	//	{
	//		/// <summary>
	//		///     Gets the instrument who executes the command .
	//		/// </summary>
	//		public Paper Ployment
	//		{
	//			get;
	//			set;
	//		}
	//		/// <summary>
	//		///     Gets or sets the date time of this command .
	//		/// </summary>
	//		public DateTime Day
	//		{
	//			get;
	//			set;
	//		}

	//		/// <summary>
	//		///     Gets or sets money size on this command
	//		/// </summary>
	//		public decimal Value
	//		{
	//			get;
	//			set;
	//		}

	//		/// <summary>
	//		///     Gets or sets the extra cost (tax, commission etc. ) of this command 
	//		/// </summary>
	//		public decimal Commision
	//		{
	//			get;
	//			set;
	//		}

	//		/// <summary>
	//		///     Gets or sets the text comment 
	//		/// </summary>
	//		public string Text
	//		{
	//			get;
	//			set;
	//		}
      
	//	}

	//	/// <summary>
	//	///     History of all commands 
	//	/// </summary>
	//	List <Command> mHistoryCommands ;



	//	/// <summary>
	//	///     c'tor
	//	/// </summary>
	//	public MoneyManager ( decimal capital)
	//	{

	//		this.Cash = capital;

	//		this.Equity = 0.0m;
	//		this.Debts = 0.0m;

	//		// todo: ??
	//	}


	//	/// <summary>
	//	///		Gets or sets available cashes by now .
	//	/// </summary>
	//	public decimal Cash
	//	{
	//		get;
	//		set;
	//	}

	//	/// <summary>
	//	///		Gets or sets value of openned positions marked-to market .
	//	/// </summary>
	//	public decimal Equity
	//	{
	//		get;
	//		set;
	//	}
	//	/// <summary>
	//	///		portfolio's total equity .
	//	///		- which is determined by the amount of cash in your account 
	//	///		-	plus the value of any open position ( long & short ). 
	//	/// </summary>
	//	public decimal TotalEquity
	//	{
	//		get { return Cash + Equity; }
	//	}


	//	/// <summary>
	//	///		Gets or sets debts to balancing marked to market
	//	/// </summary>
	//	public decimal Debts
	//	{
	//		get;
	//		set;
	//	}

	//	/// <summary>
	//	///      portfolio's debt to equity ratio 
	//	/// </summary>
	//	public decimal DebtEquityRatio
	//	{
	//		get { return Debts / TotalEquity; }
	//	}

	//	/// <summary>
	//	///     margin marked to market 
	//	/// </summary>
	//	public decimal MarginRatio
	//	{
	//		get { return (TotalEquity - Debts) / TotalEquity; }
	//	}
	//	/// <summary>
	//	///     portfolio leverage ( the ratio of loan and capital )
	//	/// </summary>
	//	public decimal LeverageRatio
	//	{
	//		// todo:
	//		get { return Debts / Cash; }
	//	}

	//	/// <summary>
	//	///     Gets the max money rationing limit for a single deal . 
	//	/// </summary>
	//	decimal QuotaLimit
	//	{
	//		get;
	//		set;
	//	}

	//	/// <summary>
	//	///     Gets the maximum drawdown of money .
	//	/// </summary>
	//	public decimal MaxDD
	//	{
	//		get;
	//		set;
	//	}

	//	/// <summary>
	//	///     Gets the maximum loss that can be tolerated
	//	/// </summary>
	//	public decimal MaxBias
	//	{
	//		get;
	//		set;
	//	}


	//	/// <summary>
	//	///		As the name indicates, Takes money from the account .
	//	/// </summary>
	//	public void withdraw( DateTime dayTime, decimal vol)
	//	{
	//		// todo: add to the account book
	//		this.Cash -= vol;
	//	}

	//	/// <summary>
	//	///		As the name indicates, Puts money into the account .
	//	/// </summary>
	//	public void deposit( DateTime dayTime, decimal vol)
	//	{
	//		// todo: add to the account book 
	//		this.Cash += vol;
	//	}

	//	/// <summary>
	//	///      
	//	///     How many( size) we can afford to open a position ?
	//	///         - according to the cash flow condition and the risk level . 
	//	/// </summary>
	//	public decimal TryRoll ( decimal risk, decimal winRate, decimal divPnL, decimal weight)
	//	{
	//		///         
	//		///      This policy is inspired by the Kelly Criterion ,
	//		///         who's looking at two Major aspects:
	//		///		    
	//		///             - W: the possibility that the system will be a winner .
	//		///		        - R: the Win/Loss Ratio,  gained from winning divided by lost from losing .
	//		///		
	//		///         So the optimal percentage of captial( Kelly %) sizing a position 
	//		///          is determined by following equation:
	//		///             
	//		///             - Kelly % = W - [ (1-W)/ R ]
	//		///         

	//		decimal /*Win Rate*/    W = 1.0m - risk ;
	//		decimal /*Win / Loss*/  R = divPnL ;

	//		decimal /*Kelly %*/     Kp = W - ((1 - W) / R) * weight;

	//		return Kp * QuotaLimit;
	//	}
	//}
}
